import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

public class Demo3 {
    public static ThreadLocal<Integer> tl = new InheritableThreadLocal<>();
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            for (int i = 0; i < 100; i++) {
                tl.set(i);
            }
            System.out.println("t1: " + tl.get());
            //可手动删除
            tl.remove();
        });
        Thread t2 = new Thread(() -> {
            for (int i = 0; i < 1000; i++) {
                tl.set(i);
            }
            System.out.println("t2: " + tl.get());
            //不手动删除就等线程结束
        });
        t1.start();
        t2.start();
        t1.join();
        t2.join();
        tl.set(88);
        System.out.println(tl.get());
    }
}
